﻿
@{
    Layout = null;
}
@model UserLoginDTO

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>系统登录</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="~/lib/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="~/lib/font-awesome/css/font-awesome.css">
    <link rel="stylesheet" href="~/lib/AdminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="~/lib/iCheck/skins/square/blue.css">
</head>
<body>
    <div class="login-box">
        <div class="login-logo">
            <a href="#" target="_blank"><b>AdminLTE</b></a>
        </div>
        <!-- /.login-logo -->
        <div class="login-box-body">
            <p class="login-box-msg">权限管理系统</p>
            <input id="errorInfo" type="hidden" value="@ViewBag.ErrorInfo" />
            <form asp-controller="Login" asp-action="Index" method="post" onsubmit="onSubmit()">
                <div class="form-group has-feedback">
                    <input asp-for="UserName" type="text" class="form-control" placeholder="用户名">
                    <span class="glyphicon glyphicon-user form-control-feedback"></span>
                </div>
                <div class="form-group has-feedback">
                    <input asp-for="Password" type="password" class="form-control" placeholder="密码">
                    <span class="glyphicon glyphicon-lock form-control-feedback"></span>
                </div>
                <div class="row">
                    <div class="col-xs-8">
                        <div class="checkbox icheck">
                            <label>
                                <input asp-for="RememberMe" type="checkbox"> 记住我
                            </label>
                        </div>
                    </div>
                    <!-- /.col -->
                    <div class="col-xs-4">
                        <button id="btnLogin" type="submit" class="btn btn-primary btn-block btn-flat">登录</button>
                    </div>
                    <!-- /.col -->
                </div>
            </form>
        </div>
        <!-- /.login-box-body -->
    </div>
    <!-- /.login-box -->
    <script src="~/lib/jquery/jquery.js"></script>
    <script src="~/lib/bootstrap/js/bootstrap.js"></script>
    <script src="~/lib/iCheck/icheck.js"></script>
    <script src="~/lib/layer/layer.js"></script>
    <script src="~/lib/jquery-cookie/jquery.cookie.js"></script>
    <script>
        $(function () {
            $('input').iCheck({
                checkboxClass: 'icheckbox_square-blue',
                radioClass: 'iradio_square-blue',
                increaseArea: '20%' // optional
            });

            //显示服务端验证的错误信息
            if ($("#errorInfo").val()) {
                layer.tips($("#errorInfo").val(), "#btnLogin");
            };

            //判断之前是否有设置cookie，如果有，则设置【记住我】选择框
            if ($.cookie("cookie_userName") != undefined) {
                $("#RememberMe").iCheck('check');
            }
            else {
                $("#RememberMe").iCheck('uncheck');
            }
            //读取cookie
            if ($("#RememberMe:checked").length > 0) {
                $("#UserName").val($.cookie("cookie_userName"));
                $("#Password").val($.cookie("cookie_password"));
            }
        });

        //根据是否勾选记住我记录或清除cookie
        function onSubmit() {
            if ($("#RememberMe:checked").length > 0) {//设置cookie
                $.cookie("cookie_userName", $("#UserName").val());
                $.cookie("cookie_password", $("#Password").val());
            } else {//清除cookie
                $.removeCookie("cookie_userName");
                $.removeCookie("cookie_password");
            }
        };
    </script>
</body>
</html>
